package com.neteast.androidclient.contact.adapter;

import java.util.ArrayList;

import com.neteast.androidclient.contact.R;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class SimpleStrAdapter extends BaseAdapter{
	private ArrayList<String> data;
	private Context context;
	private LayoutInflater mInflater;
	private int style;
	
	public SimpleStrAdapter(Context context, ArrayList<String> data, int style){
		this.context = context;
		this.data = data;
		this.mInflater = LayoutInflater.from(context);
		this.style = style;
	}
	public int getCount() {
		return data.size();
	}

	public Object getItem(int position) {
		return data.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public void removeView(int position){
		data.remove(position);
		notifyDataSetChanged();
	}
	
	public void addView(String item){
		data.add(item);
		notifyDataSetChanged();
	}
	
	public void relaceName(int position, String item){
		data.set(position, item);
		notifyDataSetChanged();
	}
	
	public View getView(int position, View convertView, ViewGroup parent) {
		convertView = mInflater.inflate(style, null);
		TextView text = (TextView) convertView.findViewById(R.id.text);
		text.setText(data.get(position));
		text.setGravity(Gravity.CENTER_HORIZONTAL);
		return convertView;
	}

}
